package 访问者设计模式;

import java.util.ArrayList;

public class Doctor {
    private ArrayList<Medicine> medicines = new ArrayList<>();

    public void addMedicine(Medicine medicine) {
        medicines.add(medicine);
        System.out.println("医生给病人开药！");
    }

    public void removeMedicine(Medicine medicine) {
        medicines.remove(medicine);
        System.out.println("医生取消了病人药！");
    }

    public void accept(Vistitor vistitor) {
        if (medicines != null) {
            for (Medicine medicine : medicines) {
                medicine.accept(vistitor);
            }
        }
    }
}
